package com.ch06.ex04;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;

import java.nio.charset.Charset;

/**
 * Created by zc on 2016/3/17.
 */
public class Test4Main {

    public static void main(String[] args){
        Charset utf8 = Charset.forName("UTF-8");
        ByteBuf buf = Unpooled.copiedBuffer("Netty in Action rocks!", utf8);
        System.out.println((char)buf.readByte());

        int readerIndex = buf.readerIndex();
        int writerIndex = buf.writerIndex();

        System.out.println("readerIndex: " + readerIndex);
        System.out.println("writerIndex: " + writerIndex);

        buf.writeByte((byte)'?');

        System.out.println("readerIndex: " + buf.readerIndex());
        System.out.println("writerIndex: " +  buf.writerIndex());


    }
}
